package gui.BeginDialogue;

import java.awt.FlowLayout;

import gui.Error.TextToInt;
import gui.Error.TextToIntException;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

public class PanelNewConcourt extends JPanel {

	private static final long serialVersionUID = 6470249455722752189L;
	private ButtonSetMode bsm; 
	private Request nbGame= new Request("Nombre de parties:");
	private Request nbPoints = new Request("Nombre de points pour gagner une partie:");
	private GameInformation gameInformation;
	
	
	public PanelNewConcourt(IBeginDialog ibg,GameInformation g){
		setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
		JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
		bsm = new ButtonSetMode("Nouveau concourt",true,ibg);
		aux.add(bsm);
		add(aux);
		add(nbGame);
		add(nbPoints);
		gameInformation=g;
	}
	
	public void newConcourt() throws TextToIntException{
		if(bsm.isSelected()){
			int ng=TextToInt.getValueOf(nbGame.getText());
			int np=TextToInt.getValueOf(nbPoints.getText());
			gameInformation.throwConcourt(ng, np);
		}
	}

	public void block(){
		nbGame.setEditable(bsm.isSelected());
		nbPoints.setEditable(bsm.isSelected());
	}
	
}
